import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.widgets.Canvas;


// TODO: Auto-generated Javadoc
/**
 * The Class NurseDoctor.
 */
public class NurseDoctor {
	
	/** The shell. */
	protected Shell shell;
	
	/** The text. */
	private Text text;

	/**
	 * Launch the application.
	 *
	 * @param args the arguments
	 */
	public static void main(String[] args) {
		Display display = Display.getDefault();
		Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
			public void run() {
				try {
					NurseDoctor window = new NurseDoctor();
					window.open();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setImage(SWTResourceManager.getImage("/Users/kennyha/Desktop/Screen shot 2011-04-01 at 1.48.24 PM.png"));
		shell.setSize(700, 500);
		shell.setText("SWT Application");
		
		Button btnCreateNewUser = new Button(shell, SWT.NONE);
		btnCreateNewUser.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnCreateNewUser.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				shell.close();
				Object window;
				window = new NewTrainer();
				((NewTrainer)window).open();
				
				
			}
		});
		btnCreateNewUser.setBounds(174, 186, 168, 30);
		btnCreateNewUser.setText("Create New Trainer");
		
		text = new Text(shell, SWT.BORDER);
		text.setBounds(67, 136, 118, 19);
		
		Label lblSearchUserBy = new Label(shell, SWT.NONE);
		lblSearchUserBy.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lblSearchUserBy.setBounds(191, 139, 98, 14);
		lblSearchUserBy.setText("Search user by: ");
		
		Button btnViewAppointments = new Button(shell, SWT.NONE);
		btnViewAppointments.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				Object window;
				shell.close();

				window = new ViewAppointments();
				((ViewAppointments)window).open();
			}
		});
		btnViewAppointments.setText("View Appointments");
		btnViewAppointments.setBounds(174, 233, 168, 30);
		
		Button btnUsersManagement = new Button(shell, SWT.NONE);
		btnUsersManagement.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				Object window;
				shell.close();
				window = new ManageUsers();
				((ManageUsers)window).open();
				
			}
		});
		btnUsersManagement.setText("Trainers Management");
		btnUsersManagement.setBounds(174, 282, 168, 30);
		
		Button btnLogOut = new Button(shell, SWT.NONE);
		btnLogOut.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				Object window;
				shell.close();
				window = new Main();
				((Main)window).open();
				
			}
		});
		btnLogOut.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnLogOut.setText("Log Out");
		btnLogOut.setBounds(174, 356, 168, 30);
		
		//adding background
		final Display display = Display.getDefault();
		Canvas canvas = new Canvas(shell, SWT.NONE);
		canvas.addPaintListener(new PaintListener() {
			public void paintControl(PaintEvent arg0) {
					 org.eclipse.swt.graphics.Image image = new org.eclipse.swt.graphics.Image(display, "/Users/kennyha/Desktop/Eclipse Workplace/employeePage.png");
					 arg0.gc.drawImage(image, 10, 10);

				        image.dispose();
				
			}
		});
		canvas.setBounds(-13, -23, 729, 500);
		
		Label lblManagement = new Label(canvas, SWT.NONE);
		lblManagement.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lblManagement.setBounds(204, 47, 262, 30);
		lblManagement.setFont(SWTResourceManager.getFont("LiSong Pro", 25, SWT.BOLD));
		lblManagement.setAlignment(SWT.CENTER);
		lblManagement.setText("Management");
		
		Button btnGo = new Button(canvas, SWT.NONE);
		btnGo.setBounds(409, 154, 77, 30);
		btnGo.setText("Search");
		
		Combo combo = new Combo(canvas, SWT.NONE);
		combo.setBounds(303, 158, 94, 22);
		combo.setItems(new String[] {"Last Name", "First Name", "Date of Birth"});
		combo.select(0);
		initDataBindings();

	}
	
	/**
	 * Inits the data bindings.
	 *
	 * @return the data binding context
	 */
	protected DataBindingContext initDataBindings() {
		//DataBindingContext bindingContext = new DataBindingContext();
		//
		return null;
	}
}
